package catdog;

public class FunctionDemo03 { public static void main(String[] args) {
    Student stu=new Student("李四");
    Cat cat=new Cat("花花");
    stu.feed(cat);
    Dog dog=new Dog("大黄");
    stu.feed(dog);
    Pig pig=new Pig("胖胖");
    stu.feed(pig);

    stu.feed(new Animal("小白"){
        @Override
        public void shout(){
            System.out.println("咯咯咯");
        }
    });

}
    static class Pig extends Animal{
        public Pig(String name){
            super(name);
        }
        @Override
        public void shout(){
            System.out.println("哼哼哼");
        }
    }
}
